﻿<!DOCTYPE html>
<html>
<head>
    <title>Odd or even</title>
    <link href="styles/js-console.css" rel="stylesheet" />
    <script src="scripts/isValidInput.js"></script>
</head>
<body>
    <label for="input">Enter integer</label>
    <input type="text" id="input" />
    <button onclick="CheckOddOrEven()">
        Odd or even
    </button>
    <div id="js-console"></div>
    <script src="scripts/js-console.js"></script>
    <script>
        //Write an expression that checks if given integer is odd or even.
        function CheckOddOrEven() {
            var number = parseInt(document.getElementById("input").value); // get entered value
            if (isValidInputNumber(number)) { // Validation
                if (number % 2 == 0) {
                    jsConsole.writeLine(number + " is even.");
                }
                else {
                    jsConsole.writeLine(number + " is odd.");
                }
            }
            else {
                jsConsole.writeLine("Enter valid number.");
            }
        }
    </script>
</body>
</html>
